package bold.module.thrift.server;

import bold.module.thrift.genapi.UserI;
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

class Server {

    /**
     * 启动 Thrift 服务器
     */
    public static void main(String[] aaa) throws TTransportException {

        // 关联处理器与实现
        TProcessor processor = new UserI.Processor<>(new UserService());

        // 设置服务端口为 7911
        TThreadPoolServer.Args args = new TThreadPoolServer.Args(new TServerSocket(7911))
                .processor(processor)
                .protocolFactory(new TBinaryProtocol.Factory());//设置协议工厂

        new TThreadPoolServer(args).serve();
        System.out.println("Start server on port 7911...");

    }
}
